package com.swust.mapper;

import com.swust.po.Product;
import org.apache.ibatis.annotations.*;

public interface ProductMapper {
	@SelectKey(keyProperty = "id", keyColumn = "id", resultType = int.class, statement = "SELECT LAST_INSERT_ID()", before = false)
	@Insert("INSERT INTO mybatis02.product(name, price, detail, pic, createtime) VALUES " +
			"(#{name},#{price},#{detail},#{pic},#{createtime})")
	void saveProduct(Product product);

	@Results({
			@Result( column = "pid", property = "id"),
			@Result( column = "pname", property = "name"),

	})
	@Select("SELECT id AS pid ,name As pname,price,detail,pic,createtime FROM mybatis02.product WHERE id=#{id}")
	Product  selectProduct(Integer id);
}
